package com.hongkzh.www.recruit.controller;

import com.hongkzh.www.adv.service.MediaService;
import com.hongkzh.www.conmon.BaseController;
import com.hongkzh.www.conmon.BusinessException;
import com.hongkzh.www.conmon.DateUtil;
import com.hongkzh.www.conmon.ReqResponse;
import com.hongkzh.www.recruit.service.RecruitService;
import com.hongkzh.www.swagger.annotation.*;
import com.jfinal.aop.Clear;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.upload.UploadFile;

import java.util.List;

/**
 * @author martins
 */
@Api(tag = "recruit", description = "招聘")
public class RecruitController extends BaseController {
    /**
     * 上传文件基础虚拟路径
     */
    public static final String USERFILES_BASE_URL = "/userfiles/1/recruit/";
    RecruitService recruitService = new RecruitService();
    MediaService mediaService = new MediaService();


    @ApiOperation(url = "/v1/recruit/getCategoryCarouselList", tag = "recruit", httpMethod = "post", description = "获取招聘主页轮播图列表")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ imgSrc 图片地址 ,imgLinks 图片链接 imgRank 图片排序  id 视频广告id carouselId 轮播图id}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryCarouselList() {
        String categoryId = getPara("categoryId");
        ReqResponse<List<Record>> r = new ReqResponse();
        r.setData(mediaService.getCategoryCarouselList(categoryId));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/getCategoryCirclesList", tag = "recruit", httpMethod = "post", description = "获取招聘圈子列表")
    @Params({
            @Param(name = "categoryId", description = "分类id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "sortId", description = "排序字段 默认 成员最多 user_count  最新创建 create_date ", required = false, dataType = "string"),
            @Param(name = "sortValue", description = "排序值 asc 升 desc 降 ", required = false, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " circleId 圈子id  name 圈子名称 coverImgWidth封面宽 coverImgHeight封面高 coverImgSrc 封面图片 uid 用户id,headImg头像 ,uName 用户名称 userCount 圈子人数"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getCategoryCirclesList() {
        String categoryId = getPara("categoryId");
        int pageNumber = getParaToInt("pageNumber");
        String sortId = getPara("sortId");
        String sortValue = getPara("sortValue");
        if (StrKit.isBlank(sortId)) {
            sortId = "user_count";
        }
        if (StrKit.isBlank(sortValue)) {
            sortValue = "desc";
        }
        ReqResponse<Page<Record>> r = new ReqResponse();
        ;

        r.setData(mediaService.getCategoryCirclesList(categoryId, pageNumber, sortId, sortValue));
        renderJson(r);
    }


    @ApiOperation(url = "/v1/recruit/getEnterpriseRecruitList", tag = "recruit", httpMethod = "post", description = "获取招聘主页职位列表")
    @Params({
            @Param(name = "title", description = "职位标题", required = false, dataType = "string"),
            @Param(name = "categoryId", description = "职位分类id", required = false, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "areaId", description = "地点id", required = false, dataType = "string"),
            @Param(name = "salaryId", description = "薪水id", required = false, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "recruitId 职位id  title 标题 areaId 区域" +
                            " salary 薪资experience经验 education 学历" +
                            "name 公司名称 headImg 公司logo coverImgSrc 封面"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getEnterpriseRecruitList() {
        String categoryId = getPara("categoryId");
        int pageNumber = getParaToInt("pageNumber");
        String areaId = getPara("areaId");
        String title = getPara("title");
        String salaryId = getPara("salaryId");
        String loginUid = getAttr("loginUid");
        ReqResponse<Page<Record>> r = new ReqResponse();
        r.setData(recruitService.getEnterpriseRecruitList(categoryId, pageNumber, areaId, salaryId, title));
        if(StrKit.notBlank(title)){
            enhance(RecruitService.class).saveSearch(loginUid,title);
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/recruitSearchHistory", tag = "recruit", httpMethod = "post", description = "职位搜索历史")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ hots 热搜索 [name] historys 搜索历史 [historyId name 名称] }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void recruitSearchHistory() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Record> r = new ReqResponse();
        Record record = recruitService.recruitSearchHistory(loginUid);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/deleteSearchHistory", tag = "recruit", httpMethod = "post", description = "删除搜索历史")
    @Params({
            @Param(name = "historyId", description = "搜索历史id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deleteSearchHistory() {
        String loginUid = getAttr("loginUid");
        String historyId = getPara("historyId");
        ReqResponse<Record> r = new ReqResponse();
        recruitService.deleteSearchHistory(loginUid, historyId);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/emptySearchHistory", tag = "recruit", httpMethod = "post", description = "清空搜索历史")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void emptySearchHistory() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Record> r = new ReqResponse();
        recruitService.emptySearchHistory(loginUid);

        renderJson(r);
    }


    @ApiOperation(url = "/v1/recruit/searchRecruit", tag = "recruit", httpMethod = "post", description = "搜索职位")
    @Params({
            @Param(name = "name", description = "搜索内容", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ title 名称 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void searchRecruit() {
        String loginUid = getAttr("loginUid");
        String name = getPara("name");
        ReqResponse<List<Record>> r = new ReqResponse();
        r.setData(recruitService.searchRecruit(loginUid, name));
        renderJson(r);
    }


    @ApiOperation(url = "/v1/recruit/getRecruitInfo", tag = "recruit", httpMethod = "post", description = "职位详情")
    @Params({
            @Param(name = "recruitId", description = "职位id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "recruitId 职位id  title 标题 introduce 职位描述 areaId 区域" +
                            " salary 薪资experience经验 education 学历 coverImgSrc 封面 imgSrc 视频地址 isAuth 1认证0否" +
                            "uid 用户id enterpriseId 公司id name 公司名称 headImg 公司logo industry 行业 " +
                            "categoryName 类别显示值  category 类别id state 1上线0下线 nature 性质 natureName 性质显示值"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getRecruitInfo() {
        String loginUid = getAttr("loginUid");
        String recruitId = getPara("recruitId");
        ReqResponse<Record> r = new ReqResponse();
        r.setData(recruitService.getRecruitInfo(loginUid, recruitId));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/getEnterpriseRecruitListById", tag = "recruit", httpMethod = "post", description = "企业职位信息")
    @Params({
            @Param(name = "enterpriseId", description = "公司id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " recruits[recruitId 职位id  title 标题 introduce 职位描述 areaId 区域" +
                            " salary 薪资experience经验 education 学历 createDate 发布时间]" +
                            "   name 公司名称 headImg 公司logo industry 行业 introduce 公司簡介 scale 规模 stage 发展阶段  isAuth 1认证0否" +
                            ""),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    @Clear
    public void getEnterpriseRecruitListById() {
        String loginUid = getAttr("loginUid");
        String enterpriseId = getPara("enterpriseId");
        ReqResponse<Record> r = new ReqResponse();
        r.setData(recruitService.getEnterpriseRecruitListById(loginUid, enterpriseId));
        renderJson(r);
    }


    @ApiOperation(url = "/v1/recruit/choiceRecruit", tag = "recruit", httpMethod = "post", description = "选择发布招聘")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ " +
                            "isEnterpriserecRuited 0 默认 1个人2企业  " +
                            "isAuth 企业认证 2默认1是0否" +
                            " userEnterpriseId  企业id" +
                            "isEnterprise 企业发布 1是0否" +
                            " userResumeId 个人简历id " +
                            "isUserResume 个人简历 1是0否" +
                            "}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void choiceRecruit() {
        String loginUid =getAttr("loginUid");
        ReqResponse<Record> r = new ReqResponse();
        Record record = recruitService.choiceRecruit(loginUid);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/updateEnterpriseInfo", tag = "recruit", httpMethod = "post", description = "保存企业详细信息")
    @Params({
            @Param(name = "enterpriseId", description = "企业id", required = true, dataType = "string"),

            @Param(name = "scale", description = "公司规模", required = true, dataType = "string"),
            @Param(name = "stage", description = "发展阶段", required = true, dataType = "string"),
            @Param(name = "headImg", description = "logo图片文件", required = true, dataType = "string"),

            @Param(name = "introduce", description = "简介", required = true, dataType = "string"),
            @Param(name = "areaId", description = "所在区域", required = true, dataType = "string"),
            @Param(name = "address", description = "企业地址", required = true, dataType = "string"),
            @Param(name = "website", description = "网站", required = true, dataType = "string"),
            @Param(name = "mailbox", description = "企业邮箱", required = true, dataType = "string"),

            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateEnterpriseInfo() {
        UploadFile head = getFile("headImg");

        String enterpriseId = getPara("enterpriseId");
        String introduce = getPara("introduce");
        String areaId = getPara("areaId");
        String address = getPara("address");
        String website = getPara("website");
        String mailbox = getPara("mailbox");

        String scale = getPara("scale");
        String stage = getPara("stage");
        String loginUid = getAttr("loginUid");
        String headImg = "";
        try {
            if (null != head) {
                headImg = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
                headImg = getFilePath(headImg, head);
            }
        } catch (Exception e) {
            e.printStackTrace();

        }

        RecruitService recruitService2 = enhance(RecruitService.class);
        ReqResponse<Record> r = new ReqResponse();
        recruitService2.updateEnterpriseInfo(enterpriseId, introduce, areaId, headImg, address, website, mailbox, scale, stage, loginUid);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/updateAuthenticationEnterpriseInfo", tag = "recruit", httpMethod = "post", description = "保存认证企业详细信息")
    @Params({
            @Param(name = "enterpriseId", description = "企业id", required = false, dataType = "string"),
            @Param(name = "userName", description = "真实姓名", required = true, dataType = "string"),
            @Param(name = "duties", description = "职务", required = true, dataType = "string"),
            @Param(name = "hrEmail", description = "接受简历的邮箱", required = true, dataType = "string"),
            @Param(name = "idCardImg", description = "身份证图片文件", required = true, dataType = "string"),
            @Param(name = "businessLicense", description = "营业执照图片文件", required = true, dataType = "string"),
            @Param(name = "name", description = "公司名称", required = true, dataType = "string"),
            @Param(name = "abbreviation", description = "公司简称", required = true, dataType = "string"),
            @Param(name = "industry", description = "行业领域", required = true, dataType = "string"),
            @Param(name = "scale", description = "公司规模", required = true, dataType = "string"),
            @Param(name = "stage", description = "发展阶段", required = true, dataType = "string"),
            @Param(name = "headImg", description = "logo图片文件", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateAuthenticationEnterpriseInfo() {
        UploadFile idCard = getFile("idCardImg");
        UploadFile businessLicense = getFile("businessLicense");
        UploadFile head = getFile("headImg");

        String idCardImg = "";
        String businessLicenseImg = "";
        String headImg = "";
        try {
            if (null != idCard) {
                idCardImg = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
                idCardImg = getFilePath(idCardImg, idCard);

            }
            if (null != businessLicense) {
                businessLicenseImg = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
                businessLicenseImg = getFilePath(businessLicenseImg, businessLicense);
            }
            if (null != head) {
                headImg = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
                headImg = getFilePath(headImg, head);
            }
        } catch (Exception e) {
            e.printStackTrace();

        }

        String enterpriseId = getPara("enterpriseId");
        String userName = getPara("userName");
        String duties = getPara("duties");
        String hrEmail = getPara("hrEmail");
        String name = getPara("name");
        String abbreviation = getPara("abbreviation");
        String industry = getPara("industry");
        String scale = getPara("scale");
        String stage = getPara("stage");
        String loginUid = getAttr("loginUid");

        RecruitService recruitService2 = enhance(RecruitService.class);
        ReqResponse<Record> r = new ReqResponse();
        Record record = recruitService2.updateAuthenticationEnterpriseInfo(enterpriseId, idCardImg, businessLicenseImg, headImg, userName, duties, hrEmail, name, abbreviation, industry, scale, stage, loginUid);
        r.setMsg(record.get("message"));
        r.setCode(record.get("code"));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/getRecruitEnterpriseInfo", tag = "recruit", httpMethod = "post", description = "获取企业信息")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ enterpriseId 企业id " +
                            "headImg 企业logo " +
                            "name 名称 abbreviation 公司简称 address 企业地址 areaId 所在区域 areaName 区域名称 " +
                            "isAuth 1是0否认证 website 网站 mailbox 企业邮箱 tel企业联系电话" +
                            "industry 行业领域id  industryName 行业领域" +
                            "scale 公司规模id scaleName 公司规模" +
                            "stage 发展阶段id stageName 发展阶段" +
                            "introduce 简介 " +
                            "userName 真实姓名 duties 职务 hrEmail 接受简历的邮箱 idCardImg 身份证图片 businessLicense 营业执照}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getRecruitEnterpriseInfo() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Record> r = new ReqResponse();
        Record record = recruitService.getRecruitEnterpriseInfo(loginUid);

        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/getRecruitPosition", tag = "recruit", httpMethod = "post", description = "职位列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ recruitId 职位id  title  名称 enterpriseId 企业id  category 类别 salary 薪资 areaId 区域  areaName 区域 experience 经验   education 学历 nature 工作性质 introduce 描述 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getRecruitPosition() {
        String loginUid = getAttr("loginUid");
        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> record = recruitService.getRecruitPosition(loginUid);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/getShieldCompany", tag = "recruit", httpMethod = "post", description = "获取用户屏蔽公司列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ companyId  corporateName 公司名称 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getShieldCompany() {
        String loginUid = getAttr("loginUid");
        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> record = recruitService.getShieldCompany(loginUid);
        r.setData(record);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/recruit/addShieldCompany", tag = "recruit", httpMethod = "post", description = "用户屏蔽公司增加")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "corporateName", description = "公司名称", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  corporateName 公司名称 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void addShieldCompany() {
        String loginUid = getAttr("loginUid");
        String corporateName = getPara("corporateName");
        ReqResponse<List<Record>> r = new ReqResponse();
        recruitService.addShieldCompany(loginUid,corporateName);

        renderJson(r);
    }
    @ApiOperation(url = "/v1/recruit/deleteShieldCompany", tag = "recruit", httpMethod = "post", description = "用户屏蔽公司删除")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "companyId", description = "公司id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  corporateName 公司名称 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deleteShieldCompany() {
        String loginUid = getAttr("loginUid");
        String companyId = getPara("companyId");
        ReqResponse<List<Record>> r = new ReqResponse();
        recruitService.deleteShieldCompany(loginUid,companyId);

        renderJson(r);
    }
    /* @ApiOperation(url = "/v1/recruit/getRecruitPositionDetailInfo", tag = "recruit", httpMethod = "post",description = "获取企业职位详细信息")
     @Params({
             @Param(name = "recruitId", description = "职位id", required = true, dataType = "string"),
             @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
     })
     @ApiResponses({
             @ApiResponse(code=200,message="成功",responseHeaders={
                     @ResponseHeader(name="code",description = " 0成功 1失败"),
                     @ResponseHeader(name="data",description = "{ }"),
                     @ResponseHeader(name="msg",description = "失败原因") })

     })
     public void getRecruitPositionDetailInfo(){
         String recruitId=getPara("recruitId");
         ReqResponse<Record> r=new ReqResponse();
         Record record=recruitService.getRecruitPositionDetailInfo(recruitId);
         r.setData(record);
         renderJson(r);
     }*/
    @ApiOperation(url = "/v1/recruit/updateRecruitPositionDetailInfo", tag = "recruit", httpMethod = "post", description = "保存企业职位详细信息")
    @Params({
            @Param(name = "recruitId", description = "职位id 没有就添加", required = false, dataType = "string"),
            @Param(name = "enterpriseId", description = "企业id", required = true, dataType = "string"),
            @Param(name = "title", description = "名称", required = true, dataType = "string"),
            @Param(name = "category", description = "类别", required = true, dataType = "string"),
            @Param(name = "salary", description = "薪资", required = true, dataType = "string"),
            @Param(name = "areaId", description = "区域id", required = true, dataType = "string"),
            @Param(name = "experience", description = "经验", required = true, dataType = "string"),
            @Param(name = "education", description = "学历", required = true, dataType = "string"),
            @Param(name = "nature", description = "工作性质", required = true, dataType = "string"),
            @Param(name = "introduce", description = "描述", required = true, dataType = "string"),
            @Param(name = "state", description = "1上线0下线", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ recruitId  有值表示修改 无值表示增加}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateRecruitPositionDetailInfo() {
        RecruitService recruitService2 = enhance(RecruitService.class);
        String recruitId = getPara("recruitId");
        String title = getPara("title");
        String salary = getPara("salary");
        String areaId = getPara("areaId");
        String experience = getPara("experience");
        String education = getPara("education");
        String nature = getPara("nature");
        String introduce = getPara("introduce");
        String category = getPara("category");
        String enterpriseId = getPara("enterpriseId");
        String state = getPara("state");
        ReqResponse<Record> r = new ReqResponse();
        recruitService2.updateRecruitPositionDetailInfo(recruitId, title, salary, areaId, experience, education, nature, introduce, category, enterpriseId,state);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/getUserInfo", tag = "recruit", httpMethod = "post", description = "获取个人信息")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ resumeId 简历id portrait 简历头像" +
                            " name 姓名 sex 性别 1男2女 sexName 性别显示值 education 学历 educationName 学历显示值 " +
                            "workingLife 工作年限 workingLifeName 工作年限显示值 birthday 生日 located 所在城市 locatedName 所在城市显示值" +
                            " mobile 联系电话 email 联系邮箱" +   " constellation 星座 constellationName 显示值" +   " marital 情感状态 maritalName 情感状态显示值" +
                            "weight 体重hobby 爱好 nickname 昵称 height 身高 occupation 职业 monthlyIncome月收入 age 年龄" +
                            "functions 期望职位  functionsName 期望职位显示值  state 当前状态 stateName 当前状态显示值" +
                            " workNature 工作性质 workNatureName 工作性质显示值 timeToPost 到岗时间 timeToPostName 到岗时间显示值" +
                            "place 期望地点 placeName 期望地点显示值 salary 期望薪资 salaryName期望薪资显示值 content 自我描述}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getUserInfo() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Record> r = new ReqResponse();
        Record record = recruitService.getUserInfo(loginUid);

        r.setData(record);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/recruit/getUserRelationship", tag = "recruit", httpMethod = "post", description = "获取用户关系")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "uid", description = "用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ type 0 默认人1好友  2我关注好友 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getUserRelationship() {
        String loginUid = getAttr("loginUid");
        String uid = getPara("uid");
        ReqResponse<Record> r = new ReqResponse();
        Record record = recruitService.getUserRelationship(loginUid,uid);

        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/updateCareerIntentions", tag = "recruit", httpMethod = "post", description = "修改职业意向")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "functions", description = "期望职位", required = true, dataType = "string"),
            @Param(name = "workNature", description = "工作性质", required = true, dataType = "string"),
            @Param(name = "salary", description = "期望薪资", required = true, dataType = "string"),
            @Param(name = "place", description = "期望地点", required = true, dataType = "string"),
            @Param(name = "state", description = "当前状态", required = true, dataType = "string"),
            @Param(name = "timeToPost", description = "到岗时间", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{     }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateCareerIntentions() {
        String loginUid = getAttr("loginUid");
        String functions = getPara("functions");
        String workNature = getPara("workNature");
        String salary = getPara("salary");
        String place = getPara("place");
        String state = getPara("state");
        String timeToPost = getPara("timeToPost");


        ReqResponse<Record> r = new ReqResponse();
        recruitService.updateCareerIntentions(loginUid, functions, workNature, salary, place, state, timeToPost);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/updateUserPortrait", tag = "recruit", httpMethod = "post", description = "修改个人简历头像")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "portrait", description = "头像文件", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{   portrait 简历头像 }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateUserPortrait() {
        UploadFile uf = getFile("portrait");


        String loginUid = getAttr("loginUid");

        ReqResponse<Record> r = new ReqResponse();

        try {
            String portraitImg= USERFILES_BASE_URL +DateUtil.FormatDateMMDD()+"/";
            portraitImg=getFilePath(portraitImg,uf);
            Record record = recruitService.updateUserPortrait(portraitImg, loginUid);
            r.setData(record);

        } catch (Exception e) {
            e.printStackTrace();

        }



        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/updateUserBaseInfo", tag = "recruit", httpMethod = "post", description = "修改个人基本信息")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "name", description = "姓名", required = true, dataType = "string"),
            @Param(name = "sex", description = "性别 1男2女", required = true, dataType = "string"),
            @Param(name = "education", description = "学历", required = true, dataType = "string"),
            @Param(name = "workingLife", description = "工作年限", required = true, dataType = "string"),
            @Param(name = "birthday", description = "生日", required = true, dataType = "string"),
            @Param(name = "located", description = "所在城市", required = true, dataType = "string"),
            @Param(name = "mobile", description = "联系电话", required = true, dataType = "string"),
            @Param(name = "email", description = "联系邮箱", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{     }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateUserBaseInfo() {
        String loginUid = getAttr("loginUid");
        String name = getPara("name");
        String sex = getPara("sex");
        String education = getPara("education");
        String workingLife = getPara("workingLife");
        String birthday = getPara("birthday");
        String located = getPara("located");
        String mobile = getPara("mobile");
        String email = getPara("email");

        ReqResponse<Record> r = new ReqResponse();
        enhance(RecruitService.class).updateUserBaseInfo(loginUid, name, sex, education, workingLife, birthday, located, mobile, email);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/recruit/updateUserData", tag = "recruit", httpMethod = "post", description = "修改个人资料")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "nickname", description = "昵称", required = true, dataType = "string"),
            @Param(name = "sex", description = "性别 1男2女", required = false, dataType = "string"),
            @Param(name = "education", description = "学历", required = true, dataType = "string"),
            @Param(name = "constellation", description = "星座", required = true, dataType = "string"),
            @Param(name = "birthday", description = "生日", required = true, dataType = "string"),
            @Param(name = "height", description = "身高", required = true, dataType = "string"),
            @Param(name = "monthlyIncome", description = "月收入", required = true, dataType = "string"),
            @Param(name = "weight", description = "体重", required = true, dataType = "string"),
            @Param(name = "located", description = "居住地", required = true, dataType = "string"),
            @Param(name = "marital", description = "情感状态(婚姻状况)", required = true, dataType = "string"),
            @Param(name = "hobby", description = "爱好", required = true, dataType = "string"),
            @Param(name = "occupation", description = "职业", required = true, dataType = "string"),
            @Param(name = "age", description = "年龄", required = false, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{     }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
 })
    public void updateUserData() {
        String loginUid = getAttr("loginUid");
        String nickname = getPara("nickname");
        String sex = getPara("sex");
        String education = getPara("education");
        String constellation = getPara("constellation");
        String birthday = getPara("birthday");
        String height = getPara("height");
        String monthlyIncome = getPara("monthlyIncome");
        String weight = getPara("weight");
        String located = getPara("located");
        String marital = getPara("marital");
        String hobby = getPara("hobby");
        String occupation = getPara("occupation");
        String age = getPara("age");

        ReqResponse<Record> r = new ReqResponse();
        enhance(RecruitService.class).updateUserData(loginUid, nickname, sex, education, constellation, birthday, height,
                monthlyIncome, weight,located,marital,hobby,occupation,age);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/recruit/updateUserContent", tag = "recruit", httpMethod = "post", description = "修改自我描述")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

            @Param(name = "content", description = "自我描述", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ resumeId 简历id   content 自我描述}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateUserContent() {
        String loginUid = getAttr("loginUid");

        String content = getPara("content");
        ReqResponse<Record> r = new ReqResponse();
        recruitService.updateUserContent(loginUid, content);

        renderJson(r);
    }
    @ApiOperation(url = "/v1/recruit/deliveryRecruitInfo", tag = "recruit", httpMethod = "post", description = "投递职位")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "recruitId", description = "职位id", required = true, dataType = "string"),
            @Param(name = "enterpriseId", description = "企业id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{ }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deliveryRecruitInfo() {
        String loginUid = getAttr("loginUid");
        String recruitId = getPara("recruitId");
        String enterpriseId = getPara("enterpriseId");

        ReqResponse<Record> r = new ReqResponse();
        try {
            enhance(RecruitService.class).deliveryRecruitInfo(loginUid, recruitId, enterpriseId);
        }catch (BusinessException e){
            r.setMsg(e.getErrMsg());
            r.setCode(1);
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/getUserEducational", tag = "recruit", httpMethod = "post", description = "获取个人教育信息列表")
    @Params({


            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  educatioId 教育id" +
                            "graduate 毕业学校  major 专业" +
                            "education 学历 graduationTime 毕业时间 enrolmentTime 开学时间}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getUserEducational() {
        String loginUid = getAttr("loginUid");

        ReqResponse<List<Record>> r = new ReqResponse();
        List<Record> record = recruitService.getUserEducational(loginUid);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/updateUserEducational", tag = "recruit", httpMethod = "post", description = "修改个人教育信息")
    @Params({
            @Param(name = "educatioId", description = "教育id 没有就添加", required = false, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "graduate", description = "毕业学校", required = true, dataType = "string"),
            @Param(name = "major", description = "专业", required = true, dataType = "string"),
            @Param(name = "education", description = "学历", required = true, dataType = "string"),

            @Param(name = "enrolmentTime", description = "开学时间", required = true, dataType = "string"),
            @Param(name = "graduationTime", description = "毕业时间", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateUserEducational() {
        String educatioId = getPara("educatioId");
        String graduate = getPara("graduate");
        String loginUid = getAttr("loginUid");
        String education = getPara("education");
        String major = getPara("major");
        String graduationTime = getPara("graduationTime");
        String enrolmentTime = getPara("enrolmentTime");
        ReqResponse<String> r = new ReqResponse();
        recruitService.updateUserEducational(educatioId, graduate, major, education, graduationTime,enrolmentTime, loginUid);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/deleteUserEducational", tag = "recruit", httpMethod = "post", description = "删除个人教育信息")
    @Params({
            @Param(name = "educatioId", description = "教育id  ", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deleteUserEducational() {
        String educatioId = getPara("educatioId");

        String loginUid = getAttr("loginUid");


        ReqResponse<String> r = new ReqResponse();
        recruitService.deleteUserEducational(educatioId, loginUid);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/getUserExperience", tag = "recruit", httpMethod = "post", description = "获取个人工作经历列表")
    @Params({


            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  experienceId 经历id" +
                            "corporateName 公司名称  job 职位 workContent 工作内容" +
                            "entryDate 入职时间 outDate 离职时间}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void getUserExperience() {
        String loginUid = getAttr("loginUid");
        String resumeId = getPara("resumeId");
        ReqResponse<List<Record>> r = new ReqResponse();


        List<Record> record = recruitService.getUserExperience(loginUid);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/updateUserExperience", tag = "recruit", httpMethod = "post", description = "修改个人工作经历")
    @Params({
            @Param(name = "experienceId", description = "经历id 没有就添加", required = false, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "corporateName", description = "公司名称 ", required = true, dataType = "string"),
            @Param(name = "job", description = "职位", required = true, dataType = "string"),
            @Param(name = "workContent", description = "工作内容", required = true, dataType = "string"),
            @Param(name = "entryDate", description = "入职时间", required = true, dataType = "string"),
            @Param(name = "outDate", description = "离职时间", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateUserExperience() {
        String experienceId = getPara("experienceId");
        String corporateName = getPara("corporateName");
        String loginUid = getAttr("loginUid");
        String workContent = getPara("workContent");
        String job = getPara("job");
        String entryDate = getPara("entryDate");
        String outDate = getPara("outDate");
        ReqResponse<String> r = new ReqResponse();
        recruitService.updateUserExperience(experienceId, corporateName, job, workContent, entryDate, loginUid, outDate);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/recruit/deleteUserExperience", tag = "recruit", httpMethod = "post", description = "删除个人工作经历")
    @Params({
            @Param(name = "experienceId", description = "经历id", required = true, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deleteUserExperience() {
        String experienceId = getPara("experienceId");

        String loginUid = getAttr("loginUid");

        enhance(RecruitService.class).deleteUserExperience(experienceId, loginUid);
        ReqResponse<String> r = new ReqResponse();
        renderJson(r);
    }

}

